[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 getpixel()              Get the Color of the Given Pixel

 #include   <graphics.h>

 unsigned far getpixel(x,y);
 int          x;
 int          y;

    getpixel() gets the color of the pixel specified by coordinates
    ('x','y').

    Returns:    The color of the specified pixel.

   -------------------------------- Example ---------------------------------

    The following statements draw and fill two rectangles with different
    fill styles and colors. The fill color of each rectangle is
    determined and circles are drawn below the rectangles and filled with
    opposite colors.

           #include <graphics.h>
           #include <conio.h>

           main()
           {
               int gdriver = DETECT;
               int gmode;
               int pcolor1, pcolor2;

               initgraph(&gdriver,&gmode,"");
               rectangle(100,50,200,100);
               setfillstyle(SOLID_FILL,GREEN);
               floodfill(110,75,WHITE);
               rectangle(300,50,400,100);
               setfillstyle(BKSLASH_FILL,BLUE);
               floodfill(310,75,WHITE);
               getch();
               pcolor1 = getpixel(110,75);
               pcolor2 = getpixel(310,75);
               circle(150,200,50);
               setfillstyle(BKSLASH_FILL,pcolor2);
               floodfill(150,200,WHITE);
               circle(350,200,50);
               setfillstyle(SOLID_FILL,pcolor1);
               floodfill(350,200,WHITE);
               getch();
               closegraph();
           }


See Also: putpixel()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson